﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DeliveryAddress.aspx.cs" Inherits="Main_Inventory_DeliveryAddress" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title> Delivery Address </title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <script src="../../JavaScript/Commons.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
//        function SelectAll() {
//            var frm = document.forms[0];
//            for (i = 0; i < frm.elements.length; i++) {

//                if (frm.elements[i].type == "checkbox" && frm.elements[i].checked==true) {
//                    //frm.elements[i].checked = document.getElementById(id).checked;
//                    alert("abc");                  
//                }
//            }
        //        }

        function SelectAll(id) {
           var elm = document.getElementsByTagName('input');
           for (var i = 0; i < elm.length; i++) {
                if (elm.item(i).type == "checkbox") {
                     if (elm.item(i).id.substring(id.lastIndexOf('_')) == id.substring(id.lastIndexOf('_'))) {
                         if (elm.item(i).type == "checkbox" && elm.item(i).id != id)
                              elm.item(i).checked = false;
                    }
                }
            }
         }

         function Getid() {
             var getdeliveryid = document.getElementById("hiddelivery").value;
               var elm = document.getElementsByTagName('input');
               for (var i = 9; i < elm.length; i++) {
                   if (elm.item(i).type == "hidden" || elm.item(i).type != "") {
                       var str = elm.item(i).id.substring(0, elm.item(i).id.lastIndexOf('_') + 1);
                       
                       if(hidval = document.getElementById(str + 'hiddelivery')!= null)
                       {
                        var hidval = document.getElementById(str + 'hiddelivery').value;
                       }
                       if (hidval == getdeliveryid) {
                          if(document.getElementById(str + 'ChkBox1')!= null)
                          {
                            document.getElementById(str + 'ChkBox1').checked = true;
                          }
                           
                       }
                   }
               }
         }
//        function submitvalue() {
//            var elm = document.getElementsByTagName('input');
//            for (var i = 0; i < elm.length; i++) {
//                if (elm.item(i).type == "checkbox" && elm.item(i).checked == true) {
//                  
//                    var str = elm.item(i).id.substring(0, elm.item(i).id.lastIndexOf('_') + 1);
//                    var hidval = document.getElementById(str + 'hiddelivery').value;
//                    var name = document.getElementById(str + 'TxtName').value;
//                    var Add = document.getElementById(str + 'TxtAddress').value;
//                    var Country = document.getElementById(str + 'TxtCountry').value;
//                    var pincode = document.getElementById(str + 'TxtPINCODE').value;

//                    var deliveryadd = name + "\r" + Add + "\r" + Country + "\r" + pincode;

//                    window.opener.document.getElementById(document.getElementById('hid1').value).value = hidval;
//                    window.opener.document.getElementById(document.getElementById('hid2').value).value = deliveryadd;
//                    self.close();
//                   }
//                }
//             }
    </script>
</head>
<body onload="Getid()">
 <form id="form1" runat="server">
    <div>
        <div align="center">
            <asp:HiddenField ID="hidadd" runat="server" />
            <asp:HiddenField ID="hid1" runat="server" />
            <asp:HiddenField ID="hid2" runat="server" />
            <asp:HiddenField ID="hiddelivery" runat="server" />
            <asp:Label ID="lblMsg" EnableViewState="false" runat="server" Font-Bold="true"></asp:Label></div>
        <asp:ScriptManager ID="SCM1" runat="server">
        </asp:ScriptManager>
        <div class="divmain">
            <acc:heading id="pagehead" runat="server" headingtext="New Delivery Address" />
        </div>
        <div style="margin-left: 10%; margin-top: 25px; margin-right: 10%;">
            <asp:Panel ID="PanelGrd" runat="server">
                <div style="margin-bottom: 5px; margin-right: 25px;">
                    <asp:Button ID="BtnAdd" Text="Add New Delivery Address" runat="server" CssClass="button1"
                        ValidationGroup="V" OnClick="BtnAdd_Click" />
                </div>
                <asp:GridView ID="grddelivery" runat="server" AutoGenerateColumns="false" CssClass="gridview"
                    PageSize="15" AllowPaging="true" DataKeyNames="DELIVERYADDID" AlternatingRowStyle-CssClass="gridview_alternate"
                    RowStyle-CssClass="gridviewitem" PagerStyle-CssClass="pgr" EmptyDataRowStyle-CssClass="emptyrow"
                    EmptyDataText="No Record Exist!" OnPageIndexChanging="grddelivery_PageIndexChanging"
                    OnSelectedIndexChanged="grddelivery_SelectedIndexChanged" 
                    >
                    <Columns>
                        <asp:TemplateField HeaderText="Select" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:CheckBox ID="ChkBox1" runat="server" onclick="SelectAll(this.id)" />
                                <asp:HiddenField ID="hiddelivery" runat="server" Value='<%#Eval("DELIVERYADDID")%>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="Name" >
                            <ItemTemplate>
                            <input type="text" ID="TxtName" runat="server" value='<%#Eval("Name")%>' style="border:0px solid white; background-color:transparent" readonly="readonly" />
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Address">
                            <ItemTemplate>
                            <input type="text" ID="TxtAddress" runat="server"  Value='<%#Eval("Address")%>' style="border:0px solid white; background-color:transparent" readonly="readonly" />                            
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="COUNTRY">
                            <ItemTemplate>
                            <input type="text" ID="TxtCountry" runat="server" value='<%#Eval("COUNTRY")%>' style="border:0px solid white; background-color:transparent" readonly="readonly" />                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Pincode">
                            <ItemTemplate>
                            <input type="text" ID="TxtPINCODE" runat="server" value='<%#Eval("PINCODE")%>' style="border:0px solid white; background-color:transparent" readonly="readonly" />
                            </ItemTemplate>
                        </asp:TemplateField>


                        <%--<asp:BoundField DataField="Name" HeaderText="Name" />
                        <asp:BoundField DataField="Address" HeaderText="Address" />
                        <asp:BoundField DataField="COUNTRY" HeaderText="Country" />
                        <asp:BoundField DataField="PINCODE" HeaderText="Pincode" />--%>
                        <asp:CommandField HeaderText="Edit" SelectText="<img src='../../Menu/images/Edit_user.png' alt='Edit'>"
                            ShowSelectButton="true" />

                    </Columns>
                </asp:GridView>

                  <div align="center">
                    <asp:Button ID="BtnSavegrid" Text="Save" runat="server" CssClass="button" ValidationGroup="V"
                       OnClientClick="submitvalue()" />
                    &nbsp;
                    <asp:Button ID="BtnCancelgrid" Text="Cancel" runat="server" CssClass="button" 
                        CausesValidation="false"   OnClientClick="self.close();" />
                </div>
            </asp:Panel>
        </div>
        <div style="margin-left: 1%; margin-right: 1%; margin-top: 25px; width: 96%; border: 1px solid #e8e8e8;">
            <asp:Panel ID="Paneltable" runat="server" Visible="false">
                <div align="left" style="margin-left: 7px; margin-bottom: 20px; margin-top: 10px;
                    width: 47%; float: left">
                    
                    <table class="tablecontent" style="width: 100%">
                        <tr>
                            <td class="headtd" colspan="2">
                                Delivery Address Details
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 40%">
                                Name<span class="required">*</span>
                            </td>
                            <td style="width: 60%">
                                <asp:DropDownList ID="DDLDeliveryName" runat="server" Width="45px">
                                </asp:DropDownList>
                                &nbsp;<asp:TextBox ID="txtDeliveryName" CssClass="input" Width="195px" runat="server"></asp:TextBox>
                           <asp:RequiredFieldValidator ID="RFVName" runat="server" ErrorMessage="*" Display="Dynamic" ValidationGroup="V" ControlToValidate="txtDeliveryName" ></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td style="vertical-align: top">
                                Address<span class="required">*</span>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDileveryAddress1" runat="server" ValidationGroup="V" CssClass="input" Width="250px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RFieldValidator1" runat="server" Display="Dynamic" ValidationGroup="V" ErrorMessage="*" ControlToValidate="txtDileveryAddress1" ></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDileveryAddress2" runat="server" CssClass="input" Width="250px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDileveryAddress3" runat="server" Width="250px" CssClass="input"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDileveryAddress4" runat="server" CssClass="input" Width="250px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Place
                            </td>
                            <td>
                                <asp:TextBox ID="DDLDileveryPlace" runat="server" Width="250px" CssClass="input"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Pincode
                            </td>
                            <td>
                                <asp:TextBox ID="txtDileveryPincode" runat="server" Width="250px" CssClass="inputnumber"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                State <span class="required">*</span>
                            </td>
                            <td>
                                <asp:DropDownList ID="DDLDileveryState" runat="server">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" InitialValue="0" Display="Dynamic" ValidationGroup="V" ErrorMessage="*" ControlToValidate="DDLDileveryState" ></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Country
                            </td>
                            <td>
                                <asp:DropDownList ID="DDLDileveryCountry" runat="server">
                                    <asp:ListItem Text="India" Value="1"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                    </table>
                </div>
                <div style="margin-bottom: 20px; margin-top: 10px; margin-left: 2%; width: 46%; float: left">
                    <table class="tablecontent" style="width: 100%;">
                        <tr>
                            <td class="headtd" colspan="2">
                                Registration Details
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 50%">
                                VAT TIN No.
                            </td>
                            <td style="width: 50%">
                                Date
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:TextBox ID="txtVat" runat="server" CssClass="input" Width="170px"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDeliveryVatDate" runat="server" Width="70px" CssClass="input"></asp:TextBox>
                                <asp:ImageButton ID="ImgDeliveryVat" runat="server" ImageUrl="~/Images/calendar.gif" />
                                <ajaxtoolkit:calendarextender id="CalExtDeliveryvat" runat="server" targetcontrolid="txtDeliveryVatDate"
                                    popupbuttonid="ImgDeliveryVat" format="dd/MM/yyyy" enabled="True" />
                                <ajaxtoolkit:maskededitextender id="DeliveryvatDateMask" runat="server" culturename="en-GB"
                                    enabled="True" targetcontrolid="txtDeliveryVatDate" masktype="Date" displaymoney="Left"
                                    acceptnegative="Left" errortooltipenabled="True" mask="99/99/9999" cultureampmplaceholder="AM;PM"
                                    culturecurrencysymbolplaceholder="£" culturedateformat="DMY" culturedateplaceholder="/"
                                    culturedecimalplaceholder="." culturethousandsplaceholder="," culturetimeplaceholder=":">
                                        </ajaxtoolkit:maskededitextender>
                                <ajaxtoolkit:maskededitvalidator id="DeliveryvatDateValmask" runat="server" controlextender="DeliveryvatDateMask"
                                    controltovalidate="txtDeliveryVatDate" emptyvaluemessage="Date is Required" invalidvaluemessage="Date is Invalid"
                                    display="Dynamic" emptyvalueblurredtext="*" validationgroup="CompanyInfo" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Inter State Tax Regn.
                            </td>
                            <td>
                                Date
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:TextBox ID="txtDeliveryInterState" runat="server" Width="170px" CssClass="input"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDeliveryInterStateDate" runat="server" Width="70px" CssClass="input"></asp:TextBox>
                                <asp:ImageButton ID="ImgBtnInterState" runat="server" ImageUrl="~/Images/calendar.gif" />
                                <ajaxtoolkit:calendarextender id="CalDateDeliveryInterState" runat="server" targetcontrolid="txtDeliveryInterStateDate"
                                    popupbuttonid="ImgBtnInterState" format="dd/MM/yyyy" enabled="True" />
                                <ajaxtoolkit:maskededitextender id="DeliveryInterStateDateMask" runat="server" culturename="en-GB"
                                    enabled="True" targetcontrolid="txtDeliveryInterStateDate" masktype="Date" displaymoney="Left"
                                    acceptnegative="Left" errortooltipenabled="True" mask="99/99/9999" cultureampmplaceholder="AM;PM"
                                    culturecurrencysymbolplaceholder="£" culturedateformat="DMY" culturedateplaceholder="/"
                                    culturedecimalplaceholder="." culturethousandsplaceholder="," culturetimeplaceholder=":">
                                        </ajaxtoolkit:maskededitextender>
                                <ajaxtoolkit:maskededitvalidator id="DeliveryInterStateDateValmask" runat="server"
                                    controlextender="DeliveryInterStateDateMask" controltovalidate="txtDeliveryInterStateDate"
                                    emptyvaluemessage="Date is Required" invalidvaluemessage="Date is Invalid" display="Dynamic"
                                    emptyvalueblurredtext="*" validationgroup="CompanyInfo" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                CENVAT
                            </td>
                            <td>
                                Date
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:TextBox ID="txtDeliveryCENVAT" runat="server" Width="170px" CssClass="input"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox ID="txtDeliveryCENVATDate" runat="server" Width="70px" CssClass="input"></asp:TextBox>
                                <asp:ImageButton ID="ImgBtnDeliveryCVNNETDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                                <ajaxtoolkit:calendarextender id="CalDateDeliveryCVNNET" runat="server" targetcontrolid="txtDeliveryCENVATDate"
                                    popupbuttonid="ImgBtnDeliveryCVNNETDate" format="dd/MM/yyyy" enabled="True" />
                                <ajaxtoolkit:maskededitextender id="CVNNETDeliveryDateMask" runat="server" culturename="en-GB"
                                    enabled="True" targetcontrolid="txtDeliveryCENVATDate" masktype="Date" displaymoney="Left"
                                    acceptnegative="Left" errortooltipenabled="True" mask="99/99/9999" cultureampmplaceholder="AM;PM"
                                    culturecurrencysymbolplaceholder="£" culturedateformat="DMY" culturedateplaceholder="/"
                                    culturedecimalplaceholder="." culturethousandsplaceholder="," culturetimeplaceholder=":">
                                        </ajaxtoolkit:maskededitextender>
                                <ajaxtoolkit:maskededitvalidator id="CVNNETDeliveryDateValmask" runat="server" controlextender="CVNNETDeliveryDateMask"
                                    controltovalidate="txtDeliveryCENVATDate" emptyvaluemessage="Date is Required"
                                    invalidvaluemessage="Date is Invalid" display="Dynamic" emptyvalueblurredtext="*"
                                    validationgroup="CompanyInfo" errormessage="AccountStartValmask" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div style="clear: both;">
                </div>
                <div align="center">
                    <asp:Button ID="btnUpdate" Text="Update" runat="server" CssClass="button" Visible="false"
                        ValidationGroup="V" OnClick="btnUpdate_Click"/>
                    &nbsp;
                    <asp:Button ID="btnSave" Text="Save" runat="server" CssClass="button" ValidationGroup="V"
                        OnClick="btnSave_Click" />
                    &nbsp;
                    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CssClass="button" CausesValidation="false"
                                 OnClick="btnCancel_Click" />
                </div>
            </asp:Panel>
        </div>
    </div>
    </form>
</body>
</html>
